﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MHYS.DEMO.Model;
using System.Web.Security;
namespace Demo
{
    public partial class Login : System.Web.UI.Page
    {

        protected int status = 0;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            if (MEYS.DEMO.BLL.UserInfoManager.ShowUserInfo(this.txtUserName.Text) != null)
            {
                if (MEYS.DEMO.BLL.UserInfoManager.CheckLogin(this.txtUserName.Text, this.txtPwd.Text))
                {
                    this.Response.Write("<script>alert('登陆成功')</script>");
                    FormsAuthentication.RedirectFromLoginPage(this.txtUserName.Text, false);
                    this.Session["User"] = MEYS.DEMO.BLL.UserInfoManager.ShowUserInfo(this.txtUserName.Text);
                }
                else
                {
                    this.Response.Write("<script>alert('登陆失败')</script>");
                }
            }
            else
            {
                this.Message.Text = "还未注册？，赶快注册吧";
                this.status++;
            }
        }


    }
}